<?php

/*
	Class: Commerce_Magento_Cart

	About: Author
		Rich Joslin

	About: License
		<http://communit.as/docs/license>
*/
class CommerceMagentoCart extends Commerce_Db_Model_Magento {

	/* Group: Instance Methods */

	/*
		Function: getItems
	*/
	function getItems() {
		try {
			return $this->client->call($this->_api_session_id, 'cart.getItems');
		} catch (Exception $e) {
			dd($e);
		}
	}

	/*
		Function: getCheckoutSessionId
	*/
	function getCheckoutSessionId() {
		try {
			return $this->_api_session_id." / ".$this->client->call($this->_api_session_id, 'cart.getCheckoutSessionId');	
		} catch (Exception $e) {
			dd($e);
		}
	}

	/*
		Function: addToCart
			Adds a line item to the current visitor's shopping cart.

		Arguments:
			$product_id - The ID of the product in the Magento database to add to the visitor's shopping cart.
			$qty - The quantity to set for this new cart item.

		Returns: void
	*/
	function addItem($product, $qty) {
		try {
			return $this->client->call($this->session, 'cart.addItem', array('session_id' => $this->session_id, 'product' => $product, 'qty' => $qty));
		} catch (Exception $e) {
			dd($e);
		}
	}

	function getMiniCartData($session_id) {
		return array('hello_world' => 'Yay!');
	}

}
